function Add-VolatileEnlistment {
<#
.SYNOPSIS
Creates a TFS workspace intended for mappings that have active churn and should be included in forward and reverse integrations.

.PARAMETER Mappings
List of mappings to include in workspace. These can be piped froman existing workspace and you can use the BranchToken and LocalPathToken to replace new server and local path values to be used for this workspace.

.PARAMETER TfsUrl
The TFS Collection URL to use for connecting to TFS

.PARAMETER LocalSourcePath
Local path where the workspace mappings should be rooted to

.PARAMETER Branch
Server path from which to root mappings

.PARAMETER BranchToken
String in the server path of the Mappings to be replaced with the Branch parameter

.PARAMETER LocalPathToken
String in the local path of the Mappings to be replaced with the LocalSourcePath parameter. The default is 'c:\'.

.PARAMETER Force
If a wokspace already exists that was not created by BigGit then add these mappings to that workspace


.EXAMPLE
Invoke-TF workfold /workspace:"SomeOtherWorkspace;Matt Wrock" | Add-VolatileEnlistment -tfsUrl http://myserver:8080/tfs -localSourcePath "c:\dev\src\" -localPathToken "c:\" -Branch $/my/branch -BranchToken $/original/branch

This will create a new workspace based on the mappings of SomeOtherWorkspace and replace server path mappings starting with $/original/branch with $/my/branch and replace local path mappings starting with c:\ with c:\dev\src\

.EXAMPLE
Invoke-TF workfold /workspace:"SomeOtherWorkspace;Matt Wrock" | Add-VolatileEnlistment -tfsUrl http://myserver:8080/tfs -localSourcePath "c:\dev\src\" -localPathToken "c:\"

This will create a new workspace based on the mappings of SomeOtherWorkspace and replace local path mappings starting with c:\ with c:\dev\src\. The server paths will be copied from the original mappings.

.EXAMPLE
Add-VolatileEnlistment -mappings " $/my/branch/folder1: c:\dev\src\folder1"," $/my/branch/folder2: c:\dev\src\folder2" -tfsUrl http://myserver:8080/tfs -localSourcePath "c:\dev\src\"

This will create a new workspace and use the mappings passed in as is since no token parameters were used.

.NOTES
If a Volatile workspace exists, the directoris of that workspace will be symbolically linked to this workspace.

.LINK
https://BigGit.Codeplex.com
Add-VolitileEnlistment
#>        
    param(
        [Parameter(position=0,Mandatory=$True,ValueFromPipeline=$True)]
        [string[]] $mappings,
        [Parameter(Mandatory=$true)]
        [string] $tfsUrl, 
        [Parameter(Mandatory=$true)]
        [string] $localSourcePath, 
        [string] $branch = $null, 
        [string] $branchToken = '$/server/path/to/branch/', 
        [string] $localPathToken = 'c:\',
        [switch] $force
    )
    begin {
        Write-BigGitMessage "Creating Volatile Enlistment of $serverPathToBranch at $localPath\Volatile\src"  -backgroundColor darkgreen
        $pipedMappings = @()
    }
    process { 
        foreach($map in $mappings){
            $pipedMappings += $map
        }
    }
    end {
        $currentDirectory = resolve-path .
        try {
            if(Add-Workspace $pipedMappings -tfsUrl $tfsUrl -localSourcePath $localSourcePath -branch $branch -branchToken $branchToken -localPathToken $localPathToken -force:$force){
                Set-BigGitConfig "VolatilePath" (resolve-path $localSourcePath).Path
                Set-Location "$localSourcePath"
                Set-NonVolatileLinks
            }
        } finally {Set-Location $currentDirectory}
    }
}